import request from '/utils/request'

export const knowAboutApi = {
  /**获取活动分类列表 */
  getKnowAboutList(params: any): Promise<DomoKnowAbout[]> {
    return request.get('/wendas', { params })
  },
  /** 创建问答 */
  creatKnowAbout(payload: any) {
    return request.post('/wendas', payload)
  },
  /** 编辑问题 */
  editorKnowAbout(id: number, payload: any) {
    return request.patch(`/wendas/${id}`, payload)
  },
  /** 获取答案列表 */
  getAnswerList(params: any): Promise<DomoFeed[]> {
    return request.get('/wenda-comments', { params })
  },
  /** 获取指定问题的答案列表 */
  getSpaceilAnswerList(id: number, params: any): Promise<DomoFeed[]> {
    return request.get(`/wendas/${id}/comments`, { params })
  },
  /** 获取问题详情 */
  getknowAboutDetail(id: number, params: { with: string }): Promise<DomoKnowAbout> {
    return request.get(`/wendas/${id}`, { params })
  },
  /** 收藏/取消收藏问题 */
  collectKnowAbout(id: number, favorited: boolean) {
    return favorited
      ? request.delete(`/wendas/${id}/favorite`)
      : request.put(`/wendas/${id}/favorite`)
  },
  /** 采纳答案 */
  chooseAnswer(wendaId: number, feedId: number) {
    return request.post(`/wendas/${wendaId}/adoption/${feedId}`)
  },
  /** 删除问题 */
  deleteKnowAbout(id: number) {
    return request.delete(`/wendas/${id}`)
  },
}
